#! /usr/bin/python
#-*- coding: UTF-8 -*-

print "hello world"

def getTrue():
    print "debug: true"
    return 1

def getFalse():
    print "debug: false"
    return 0

def testboolen():
    if getTrue() and getFalse():
        print "ok"
    else:
        print "bad"

testboolen()

#test the list, the keyworld []
def printlist(a):
    n=-len(a)
    print "====================================="
    while n < len(a):
        print "a[",n,"]=",a[n]
        n = n + 1
    n = 0
    for k in a:
        print "a[",n,"]=",k
        n = n + 1
    print "====================================="

def listtest():
    a=[1,3,2,6,3]
    print a[:]
    print a[:3]
    print a[1:]
    print a[1:-1]
    print a.count(3)
    a.append(7);
    print(a)
    print "the length of the array is ",len(a)
    a.extend([10,11,12])
    print(a)
    a.insert(0,33)
    print(a)
    print a.index(3)
    a.pop()
    print(a)
    a.pop(0)
    print(a)
    a.reverse()
    a.remove(1)
    print(a)
    a.sort()
    print(a)
    print [k+1 for k in a]
    #print [k for k in a if type(k)==types.IntType]
listtest()

#test string operation
def stringtest():
    #print test
    print "%s's height is %x %u %c\n"%("laowang", 190, -1, 67)
    print "%r"%({"one":1,"two":2})
    print "%s"%({"two":2,"onw":1})
    print "%(name)s's height is %(height)d"%{"name":"laowang","height":170}
    #member function
    print '[',"hello world".ljust(16),']'
    print "hello world".rjust(16)
    print '[',"hello world".center(16),']'
    print '[',"hello world".center(16).rstrip(),']'
    print '[',"hello world".center(16).rstrip().lstrip(),']'
    print '[',"hello world".ljust(16).strip(),']'

    print "\n".join(["hello", "world", "python", "said"])
    print "this is a book".split(" ")
stringtest()

#test tuple
def tupletest():
    a,b = (1,2)
    print a,b
    t = (2,3)
    a,b = t
    print a,b
    a,b = b,a+1
    print a,b
tupletest()

def sequencetest():
    #sequence includes string,list and tuple
    ch = 'k'
    str = "abck"
    if ch in str:
        print "ok"

    print (1,2)*3
    print (2,2,3)[0:-1]
sequencetest()

def dictionarytest():
    #constuction
    pricelist={"dest":100, "talbe":101, "xiao":1}
    print pricelist["dest"]
    #test delete and add
    del pricelist["dest"]
    print pricelist
    pricelist["hha"] = 1
    print pricelist
    pricelist.clear()
    print pricelist
    #another constuction
    pricelist = dict([('clock',12), ("table",100),("xiao", 1)])
    print pricelist
    numlist = dict((x, 10*x) for x in [1, 2, 3])
    print numlist
    print numlist.items()
    #test copy()
    numlist = pricelist.copy()
    numlist["table"] = 99
    print numlist
    print pricelist

    numlist = pricelist
    numlist["table"] = 99
    print numlist
    print pricelist
    #test look up
    print pricelist.get("ha")
    print pricelist.get("table")
    print pricelist.get("table", 101)
    print pricelist.get("abc", 90) #not inserted

    print numlist.has_key("one")
    print numlist.has_key("table")
    print numlist
    print pricelist
    #items ,keys and values
    print pricelist.items()
    print pricelist.keys()
    print pricelist.values()
    #test update to accomplish assignment from one dict to another
    #get the union of two dictionaries
    a = dict([("table", 89), ("abc",100)])
    print a
    print pricelist
    a.update(pricelist)
    print a
    #test popitem from the beginning
    print a.popitem()
    print a.popitem()
    print a


dictionarytest()

#回文
import string
import copy
def  huiwen():
    inputString = raw_input("请输入要判断的字符串:\n")
    #get rid of useless chacarter
    punctuation = string.punctuation
    identify = ' ' * 32
    table = string.maketrans(punctuation, identify)
    new = inputString.translate(table).replace(' ', '')

    inputString = list(new)
    temp = copy.deepcopy(inputString)
    inputString.reverse()
    print inputString
    print temp
    if temp==inputString:
        print "Yes"
    else:
        print "No"

huiwen()
